let convert = function(s, numRows) {
    if (numRows == 1) return s;
    let res = '';
    let n = s.length, len = 2 * numRows - 2;
    for (let i = 0; i < numRows; i++) {
        for (let j = 0; j + i < n; j += len) {
            res += s[j + i];
            if (i != 0 && i != numRows - 1 && j + len - i < n)
                res += s[j + len - i];
        }
    }
    return res;
}